home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-03 | 1.9 KB | 42 lines | [TEXT/R*ch] |
- (* ListPair -- SML Standard Library *)
-
- val zip : 'a list * 'b list -> ('a * 'b) list
- val unzip : ('a * 'b) list -> 'a list * 'b list
- val map : ('a * 'b -> 'c) -> 'a list * 'b list -> 'c list
- val app : ('a * 'b -> unit) -> 'a list * 'b list -> unit
- val all : ('a * 'b -> bool) -> 'a list * 'b list -> bool
- val exists : ('a * 'b -> bool) -> 'a list * 'b list -> bool
-
- (* These functions process pairs of lists. No exception is raised
- when the lists are found to be of unequal length. Instead the
- excess elements from the longer list are disregarded.
-
- [zip (xs, ys)] returns the list of pairs of corresponding elements
- from xs and ys.
-
- [unzip xys] returns a pair (xs, ys), where xs is the list of first
- components of xys, and ys is the list of second components from
- xys. Hence zip (unzip xys) has the same result and effect as xys.
-
- [map f (xs, ys)] applies function f to the pairs of corresponding
- elements of xs and ys and returns the list of results. Hence
- map f (xs, ys) has the same result and effect as List.map f (zip (xs, ys)).
-
- [app f (xs, ys)] applies function f to the pairs of corresponding
- elements of xs and ys and returns (). Hence app f (xs, ys) has the
- same result and effect as List.app f (zip (xs, ys)).
-
- [all p (xs, ys)] applies predicate p to the pairs of corresponding
- elements of xs and ys until p evaluates to false or one or both
- lists is exhausted; returns true if p is true of all such pairs;
- otherwise false. Hence all p (xs, ys) has the same result and
- effect as Lisp.all p (zip (xs, ys)).
-
- [exists p (xs, ys)] applies predicate p to the pairs of corresponding
- elements of xs and ys until p evaluates to true or one or both
- lists is exhausted; returns true if p is true of any such pair;
- otherwise false. Hence exists p (xs, ys) has the same result and
- effect as Lisp.exists p (zip (xs, ys)).
-
- *)
-